<!-- login.html -->
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f4f4f4;
        }
        .container {
            max-width: 400px;
            margin: 100px auto;
            padding: 20px;
            background-color: #fff;
            border-radius: 5px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }
        h2 {
            text-align: center;
            color: #333;
        }
        input[type="text"],
        input[type="password"] {
            width: 100%;
            padding: 10px;
            margin: 10px 0;
            box-sizing: border-box;
            border: 1px solid #ccc;
            border-radius: 5px;
        }
        button {
            width: 100%;
            padding: 10px;
            margin: 10px 0;
            box-sizing: border-box;
            background-color: #007bff;
            color: #fff;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }
        button:hover {
            background-color: #0056b3;
        }
        .error-message {
            color: #ff0000;
            text-align: center;
        }
    </style>
</head>
<body>
<div class="container">
    <h2>登录</h2>
    <form id="login-form" onsubmit="return login()">
        <input type="text" id="username" placeholder="请输入账号" required>
        <input type="password" id="password" placeholder="请输入密码" required>
        <button type="submit">登录</button>
        <p class="error-message" id="error-message"></p>
    </form>
</div>
<script>
        function login() {
            var username = document.getElementById('username').value;
            var password = document.getElementById('password').value;
            // 这里可以添加验证逻辑，比如检查用户名和密码是否符合要求
            // 这里简单起见，直接假设用户名和密码都是 admin
            if ((username === 'root' && password === 'root') || (username === 'admin' && password === 'admin')) {
                localStorage.setItem('loggedInUser', username);
                window.location.assign('welcome.html');
            } else {
                document.getElementById('error-message').textContent = '账号或密码错误，请重新输入。';
                return false;
            }
        }
    </script>
</body>
</html>
